﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;

namespace SMS.Service
{
    class Program
    {
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        static void Main()
        {
            System.ServiceProcess.ServiceBase[] ServicesToRun;
            ServicesToRun = new System.ServiceProcess.ServiceBase[] { new SMSService() };
            System.ServiceProcess.ServiceBase.Run(ServicesToRun);
            //ConsoleMain();
        }

        #region 控制台启动

        static void ConsoleMain()
        {
            OnStart();
            Console.WriteLine("===========SMSService Start================");
            Console.Read();
        }

        static ServiceHost m_service;
        static void OnStart()
        {
            if (m_service == null)
            {
                //Uri baseAddress = new Uri("http://localhost:8001/");
                //m_service = new ServiceHost(typeof(CommSMSService), baseAddress);
                //m_service.AddServiceEndpoint(typeof(ISMSService), new BasicHttpBinding(), "http://localhost:8001/");
                //ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
                //smb.HttpGetEnabled = true;
                //m_service.Description.Behaviors.Add(smb);

                m_service = new ServiceHost(typeof(CommSMSService));
                var message = string.Empty;
                new CommSMSService().Start(out message);
            }
            try
            {
                m_service.Open();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }

        #endregion
    }
}
